<h3><B>商户</B></h3>
<br>
<a ng-click="addRetailer()" class="btn-primary btn-sm nodecoration">添加商户</a>
<a ng-show="parentId !=0" ng-click="backRetailer()" class="btn-primary btn-sm nodecoration">返回</a>
<br>
<br>
<div class="tab-content">
    <div class="tab-pane active" id="tab_a">
        <table class="table table-condensed">
            <thead>
            <tr>
                <th>商户编号</th>
                <th>商户名称</th>
                <th>商户地址</th>
                <th>联系人</th>
                <th>联系电话</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <tr ng-repeat="retailer in retailerList">
                <td>{{retailer.code}}</td>
                <td>{{retailer.retailer_name}}</td>
                <td>{{retailer.address}}</td>
                <td>{{retailer.contact_name}}</td>
                <td>{{retailer.phone}}</td>
                <td><a class="btn btn-secondary btn-xs" ng-click="editRetailer(retailer)"> 编辑</a>
                    <a class="btn btn-secondary btn-xs" data-toggle="modal"
                       ng-click="initRetailerCommunity(retailer.community)"
                       data-target="#community_model{{$index}}"
                            >小区设置</a>

                    <div class="modal fade" id="community_model{{$index}}" tabindex="-1" role="dialog"
                         aria-labelledby="helpModalLabel"
                         aria-hidden="true">
                        <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal"><span
                                            aria-hidden="true">&times;</span><span
                                            class="sr-only">Close</span></button>
                                    <h5 class="modal-title">设置小区</h5>
                                </div>
                                <div class="modal-body">
                                    <form class="form-horizontal" name="backendUserForm">
                                        <div>
                                            <label ng-repeat="m in communityLabelList.data">
                                                <input style="zoom:1.8;margin-left: 10px;vertical-align:middle"
                                                       type="checkbox" ng-model="chk"
                                                       ng-click="toggle(chk,m.objId,retailer.communities)"
                                                       ng-checked="retailer.communities.indexOf(m.objId)!=-1"/>{{m.communityName}}
                                            </label>
                                        </div>
                                        <div class="modal-footer">
                                            <button type="submit" class="btn btn-default" data-dismiss="modal"
                                                    ng-click="saveRetailerCommunity(retailer)">
                                                保存
                                            </button>
                                            <button type="button" class="btn btn-default" data-dismiss="modal">取消
                                            </button>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                    <a class="btn btn-secondary btn-xs" ng-click="">商家合作管理</a>
                    <a ng-show="parentId == 0" class="btn btn-secondary btn-xs"
                       ng-click="getRetailerBranch(retailer.id)">分店管理</a></td>
            </tr>
            </tbody>
        </table>
    </div>
</div>

<div class="modal fade" id="retailer_model1" tabindex="-1" role="dialog" aria-labelledby="helpModalLabel"
     aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
                        class="sr-only">Close</span></button>
                <h5 class="modal-title" id="myModalLabel"><span ng-show="parentId == 0">商户总店</span><span
                        ng-show="parentId != 0">商户分店</span></h5>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" name="backendUserForm">
                    <div class="form-group">
                        <label for="inputLoginId" class="control-label col-xs-2">商铺名称:</label>

                        <div class="col-xs-3">
                            <input type="text" class="form-control" ng-model="retailer.retailer_name"
                                   required>
                        </div>
                    </div>
                    <div id='d_code' class="form-group" ng-show="parentId !=0">
                        <label for="inputUserName" class="control-label col-xs-2">66编码:</label>

                        <div class="col-xs-3">
                            <input type="text" class="form-control" ng-model="retailer.code"
                                   required>
                            <span style="color: #a94442">{{codeErrMsg}}</span>
                        </div>
                    </div>
                    <div class="form-group" ng-show="parentId !=0">
                        <label for="inputLoginId" class="control-label col-xs-2">商铺地址:</label>

                        <div class="col-xs-3">
                            <input type="text" class="form-control" ng-model="retailer.address"
                                   required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="inputUserName" class="control-label col-xs-2">联系人:</label>

                        <div class="col-xs-3">
                            <input type="text" class="form-control" ng-model="retailer.contact_name"
                                   required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="inputUserName" class="control-label col-xs-2">联系电话:</label>

                        <div class="col-xs-3">
                            <input type="text" class="form-control" ng-model="retailer.phone"
                                   required>
                        </div>
                    </div>

                    <div class="form-group" ng-show="parentId !=0">
                        <label for="inputUserName" class="control-label col-xs-2">商铺图标:</label>

                        <div class="col-xs-5">
                            <input type="file" id="pict"
                                   onchange="angular.element(this).scope().selectFile(this.files)">
                            <img ng-show="retailer.retailer_icon!=null" ng-src="{{retailer.retailer_icon}}"/>
                        </div>
                    </div>

                    <div class="modal-footer">
                        <button id="saveButton" type="submit" class="btn btn-default" ng-click="saveRetailer(retailer)">
                            保存
                        </button>
                        <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="cancelSave()">取消
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>